export function walkParent(element: any, callback: Function) {
    if(!element) return
    let cur = element
    let stop = false
    const callbreak =() => {
        stop = true
    }
    while(cur.parent) {
        callback(cur.parent, callback)
        if(stop) {
            break
        }
        cur = cur.parent
    }
}
export function findRelativeTo(element: any) {
    if (element.isInFlow()) return element.parent;
    if (element.isFixed) return element.root;
    let relativeTo: boolean|null = null

    walkParent(element, (parent: any) =>{
        if(parent.style.position !== 'static' && !relativeTo) {
            relativeTo = parent
        }
    })
    if(!relativeTo) {
        relativeTo = element.root
    }
    return relativeTo
}